package com.sx.zongzhi.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.ServiceRecordBean;
import com.sx.zongzhi.utils.BaseUtil;

import java.util.List;


/**
 * Created by XZY on 2017/11/23.
 * 服务记录
 */

public class ServiceRecordAdapter extends BaseQuickAdapter<ServiceRecordBean.RowsBean,BaseViewHolder> {

    private Context context;

    public ServiceRecordAdapter(Context context, @LayoutRes int layoutResId,
                                @Nullable List<ServiceRecordBean.RowsBean> data) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ServiceRecordBean.RowsBean item) {
        helper.setText(R.id.tv_Name,item.getServiceMembers());
        helper.setText(R.id.tv_Time,item.getOccurDate());
        helper.setText(R.id.tv_Title,item.getObjectTypeName()+"("+item.getServiceObjects()+")");
        helper.setText(R.id.tv_Content,"  "+item.getServiceContent());
        ImageView imageView=helper.getView(R.id.imv_Type);
        if (!BaseUtil.isEmpty(item.getSuffixType())){
            imageView.setVisibility(View.VISIBLE);
            String type=item.getSuffixType();
            if (".mp4".equalsIgnoreCase(type)){
                imageView.setImageResource(R.mipmap.icon_video);
            }else if (".amr".equalsIgnoreCase(type)){
                imageView.setImageResource(R.mipmap.icon_audio);
            }else if (".jpeg".equalsIgnoreCase(type)||".jpg".equalsIgnoreCase(type)||
                    ".png".equalsIgnoreCase(type)){
                imageView.setImageResource(R.mipmap.icon_picture);
            }else {
                imageView.setVisibility(View.GONE);
            }
        }else {
            imageView.setVisibility(View.GONE);
        }
    }
}
